package com.ag.zlw.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;

import com.ag.zlw.service.impl.RoleServiceImpl;
import com.ag.bean.TbRole;
import com.ag.common.AjaxNotify;
import com.ag.common.BaseAction;
import com.ag.common.IDUtil;
import com.ag.common.IIDService;

@Controller("AllRoleAction")
public class RoleAction extends BaseAction {
	private static final Logger logger = Logger.getLogger(RoleAction.class);
	private static final long serialVersionUID = 1254755643842522902L;

	@Resource(name = "RoleService")
	private RoleServiceImpl roleService;
	@Resource(name = "iDServiceImpl")
	private IIDService idServiceImpl;
	private TbRole role;
	private List<TbRole> roles;

	/**
	 * 角色ID
	 */
	private String RId;

	/**
	 * 异步请求结果返回
	 */
	private String ajaxRst;

	public String getAjaxRst() {
		return ajaxRst;
	}

	public void setRId(String rId) {
		RId = rId;
	}

	public String getRId() {
		return RId;
	}

//	/**
//	 * 根据ID删除角色
//	 * 
//	 * @return
//	 */
//
//	public String delRoleById() {
//		try {
//			roleService.delete(RId);
//			ajaxRst = AjaxNotify.SUCCESS;
//			return "operate";
//		} catch (Exception e) {
//			e.printStackTrace();
//			ajaxRst = AjaxNotify.EXCEPTION;
//			return "operate";
//		}
//	}
//
//	public String save() {
//		if (!role.getRName().isEmpty()) {
//			try {
//				String RId = idServiceImpl.findTablePK(IDUtil.TB_ROLE);
//				role.setRId(RId);
//				role.setA(IDUtil.PRESERVE);
//				if (this.roleService.save(role)) {
//					ajaxRst = AjaxNotify.SUCCESS;
//				} else {
//					ajaxRst = AjaxNotify.EXCEPTION;
//				}
//
//			} catch (Exception e) {
//				e.printStackTrace();
//				ajaxRst = AjaxNotify.EXCEPTION;
//			}
//		}
//		return "operate";
//	}

	public String findAllRole() {
		roles = this.roleService.findAllRole();
		return "findAllRole";
	}

	public TbRole getRole() {
		return role;
	}

	public void setRole(TbRole role) {
		this.role = role;
	}

	public List<TbRole> getRoles() {
		return roles;
	}

	public void setRoles(List<TbRole> roles) {
		this.roles = roles;
	}
}
